package com.txunda.zhuohired.http;

import com.ants.theantsgo.base.BaseView;
import com.ants.theantsgo.config.Config;
import com.ants.theantsgo.httpTools.ApiTool2;
import com.lidroid.xutils.http.RequestParams;

/**
 * 创建人： Txd_Cjh
 * 创建时间： 2018/3/27 14:15
 * 功能描述：用户登录
 * 联系方式：jiahuanchen@126.com
 */

public class Account {
    private static String url = Config.BASE_URL + "Account/";

    /**
     * 注册
     *
     * @param phone         手机号
     * @param code          验证码
     * @param password      密码
     * @param againpassword 确认密码
     * @param baseView
     */
    public void register(String phone, String code, String password, String againpassword, BaseView baseView) {
        RequestParams params = new RequestParams();
        ApiTool2 apiTool = new ApiTool2();
        params.addBodyParameter("phone", phone);
        params.addBodyParameter("code", code);
        params.addBodyParameter("password", password);
        params.addBodyParameter("againpassword", againpassword);
        apiTool.postApi(url + "register", params, baseView);
    }

    /**
     * 登录
     *
     * @param phone    手机号
     * @param password 密码
     * @param baseView
     */
    public void login(String phone, String password, BaseView baseView) {
        RequestParams params = new RequestParams();
        ApiTool2 apiTool = new ApiTool2();
        params.addBodyParameter("phone", phone);
        params.addBodyParameter("password", password);
        apiTool.postApi(url + "login", params, baseView);
    }

    /**
     * 忘记密码
     *
     * @param phone         手机号
     * @param code          验证码
     * @param password      密码
     * @param againpassword 确认密码
     * @param baseView
     */
    public void forgetPassword(String phone, String code, String password, String againpassword, BaseView baseView) {
        RequestParams params = new RequestParams();
        ApiTool2 apiTool = new ApiTool2();
        params.addBodyParameter("phone", phone);
        params.addBodyParameter("code", code);
        params.addBodyParameter("password", password);
        params.addBodyParameter("againpassword", againpassword);
        apiTool.postApi(url + "forgetPassword", params, baseView);
    }

    /**
     * 选择身份
     *
     * @param token       登陆成功之后的id
     * @param baseView
     */
    public void choose(String token, BaseView baseView) {
        RequestParams params = new RequestParams();
        ApiTool2 apiTool = new ApiTool2();
        params.addBodyParameter("token", token);
        apiTool.postApi(url + "choose", params, baseView);
    }
}
